package wx.request;

import util.DateUtil;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author zhanglinfeng
 * @date create in 2022/5/30 13:40
 */
public class PayInfo {
    private String appid;
    private String mch_id;
    private String device_info;
    private String nonce_str;
    private String sign_type;
    private String body;
    private String attach;
    private String out_trade_no;
    private int total_fee;
    private String spbill_create_ip;
    private String time_start;
    private String time_expire;
    private String notify_url;
    private String trade_type;
    private String limit_pay;
    private String openid;

    public PayInfo() {
    }

    public PayInfo(String appId,String mchId,String urlNotify,String openId, String clientIP, String randomNonceStr,String body,String attach,String tradeNo,String totalFee) {
        String timeStart = DateUtil.nowStr(DateUtil.YYYYMMDDHHMMSS);
        String timeExpire = LocalDateTime.now().plusMinutes(30).format(DateTimeFormatter.ofPattern(DateUtil.YYYYMMDDHHMMSS));
        BigDecimal data1Decimal = new BigDecimal(totalFee).setScale(6, RoundingMode.HALF_UP);
        BigDecimal data2Decimal = new BigDecimal(100);
        this.appid = appId;
        this.mch_id = mchId;
        this.device_info = "WEB";
        this.nonce_str = randomNonceStr;
        this.sign_type = "MD5";  //默认即为MD5
        this.body = body;
        this.attach = attach;
        this.out_trade_no = tradeNo;
        this.total_fee = data1Decimal.multiply(data2Decimal).intValue();
        this.spbill_create_ip = clientIP;
        this.time_start = timeStart;
        this.time_expire = timeExpire;
        this.notify_url = urlNotify;
        this.trade_type = "JSAPI";
        this.limit_pay = "no_credit";
        this.openid = openId;
    }

    public String getAppid() {
        return this.appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String getMch_id() {
        return this.mch_id;
    }

    public void setMch_id(String mch_id) {
        this.mch_id = mch_id;
    }

    public String getDevice_info() {
        return this.device_info;
    }

    public void setDevice_info(String device_info) {
        this.device_info = device_info;
    }

    public String getNonce_str() {
        return this.nonce_str;
    }

    public void setNonce_str(String nonce_str) {
        this.nonce_str = nonce_str;
    }

    public String getSign_type() {
        return this.sign_type;
    }

    public void setSign_type(String sign_type) {
        this.sign_type = sign_type;
    }

    public String getBody() {
        return this.body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getAttach() {
        return this.attach;
    }

    public void setAttach(String attach) {
        this.attach = attach;
    }

    public String getOut_trade_no() {
        return this.out_trade_no;
    }

    public void setOut_trade_no(String out_trade_no) {
        this.out_trade_no = out_trade_no;
    }

    public int getTotal_fee() {
        return this.total_fee;
    }

    public void setTotal_fee(int total_fee) {
        this.total_fee = total_fee;
    }

    public String getSpbill_create_ip() {
        return this.spbill_create_ip;
    }

    public void setSpbill_create_ip(String spbill_create_ip) {
        this.spbill_create_ip = spbill_create_ip;
    }

    public String getTime_start() {
        return this.time_start;
    }

    public void setTime_start(String time_start) {
        this.time_start = time_start;
    }

    public String getTime_expire() {
        return this.time_expire;
    }

    public void setTime_expire(String time_expire) {
        this.time_expire = time_expire;
    }

    public String getNotify_url() {
        return this.notify_url;
    }

    public void setNotify_url(String notify_url) {
        this.notify_url = notify_url;
    }

    public String getTrade_type() {
        return this.trade_type;
    }

    public void setTrade_type(String trade_type) {
        this.trade_type = trade_type;
    }

    public String getLimit_pay() {
        return this.limit_pay;
    }

    public void setLimit_pay(String limit_pay) {
        this.limit_pay = limit_pay;
    }

    public String getOpenid() {
        return this.openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }
}
